$('[name="login"]').click(function () {
    window.location.href = `../pages/login.html?url=${window.location.href}`
})

$('[name="loginout"]').click(function () {
    const cookieObj = myGetCookie();

    if (cookieObj.login === undefined) {
        if (window.confirm('您还没有登录,点击确定跳转登录页')) {
            window.location.href = '../pages/login.html';
        }
    } else {
        mySetCookie('login', 1, -1, '/');
        window.alert('您已经退出登录');
    }
})

$('[name="cart"]').click(function () {
    const cookieObj = myGetCookie();

    if (cookieObj.login === undefined) {
        if (window.confirm('您还没有登录,点击确定跳转登录页')) {
            window.location.href = '../pages/login.html';
        }
    } else {
        window.location.href = '../pages/cart.html';
    }
})


loadList()

function loadList() {
    const tagKind = document.querySelectorAll('.centerType a');
    const ifr = document.createElement('iframe');
    ifr.scrolling = 'no'
    ifr.remove();
    let str = '';
    $('[class="centerType"]').mouseover(e => {
        if (e.target.tagName === 'A') {
            $('[name="first_load"]').remove();
            console.log($(e.target).html());
            if ($(e.target).html() !== '其他产品') {
                ifr.style.display = 'block';
                $('[class="box"]').css({'display':'none'});
                ifr.setAttribute('src', `../pages/list.html?cat_one_id=${$(e.target).html()}`);
                document.body.appendChild(ifr);
            }else{
                ifr.style.display = 'none';
                $('[class="box"]').css({'display':'block'});
            }
            
        }
    })
}

